package com.core.typesafe;

public class MainClass<T extends Animal> {

    public void eat(T t) {
        if (t == null) {
            System.out.println("======= This can't be null");
        } else {
            t.eat();
        }
    }

    // This is the only one way to write the mothods having the same name and
    // same arguments. (Note in actually the argument type is different) 
    public <S extends Animal> void getMe(S s) {
        System.out.println("-------------------> " + s);
    }
    
    public <S> void getMe(S s) {
        System.out.println("-------------------> " + s);
    }


    public static void main(String[] args) {
        MainClass<Dog> demo = new MainClass<Dog>();
        demo.eat(new Dog());
        demo.getMe(new Dog());
        demo.getMe(new Horse());
    }

}
